import DList from "@/components/dlist";
import evaluationPopup from "../../home/components/evaluation_popup";
import { Image as VanImage } from 'vant';
export default {
  data() {
    return {
      order_type:'',//1-完成订单、2-待服务、3-取消、4-待接单、5-已完成并且已经评价过了
      name:"",//skill-技能师傅 、 area-区域代管理
      evaluation_show: false,
      timeList: [{
        id: 1,
        name: '接单时间',
        time:""
      },{
        id: 2,
        name: '完成时间',
        time:""
      }],
      type: "individual",
      point:{},
      info:{},
      is_evaluate:0,
    };
  },
  activated() {
    this.evaluation_show = false;
    console.log(this.$route.params,222);
    this.order_type = this.$route.params.order_type;
    this.oid = this.$route.params.order_id;
    this.type = this.$route.params.name;
    let myLocation =JSON.parse(localStorage.getItem('myLocation'));
    this.point = myLocation.point;

    this.getData();
  },
  methods: {
    goToAdress() {
      let point = this.fun.bd_decrypt(this.info.longitude, this.info.latitude);
      this.fun.goToWXAdress(point, this.info.full_address, '');
    },
    commentEvent(){
      this.getData();
      this.order_type="5";
    },
    evaluate_handle(){
      this.evaluation_show = true;
      // let url = "";
      // if(info.need_type == 1){
      //   url= 'plugin.be-within-call.frontend.need-order-operate.shi-fu-remark'
      // }else{
      //   url = 'plugin.be-within-call.frontend.need-order-operate.push-remark';
      // }
      this.urlStr = "plugin.be-within-call.frontend.need-order-operate.shi-fu-remark";

    },
    getData(){
      $http.get("plugin.be-within-call.frontend.area-manage.order-detail",{oid:this.oid,lng:this.point.lng,lat:this.point.lat},'').then(res=>{
        if(res.result){
          this.info = res.data;
          if(this.order_type=="1" || this.order_type=="5"){
            this.timeList[0].time =  res.data.accept_time
            this.timeList[1].time =  res.data.complete_time
          }
        }else{
          this.$toast(res.msg);
        }
      })
    },
    order_status(){
      if(this.order_type == '3'){
        return '已取消'
      }else if(this.order_type == '2'){
        return '待服务'
      }else if(this.order_type == '1'){
        return '已完成'
      }else{
        return '待接单'
      }
    },
    order_receiving(){
      $http.post('plugin.be-within-call.frontend.need-order-operate.receive',{oid:this.info.order_id},'').then(({result,msg,data})=>{
        this.$toast(msg);
        if(result){
          this.order_type =data.status;
          this.getData();
        }
      })
    },
  },
  components: { DList , evaluationPopup,VanImage }
};
